<template>
	<view class="container">

		<!-- <view class="wechatapp">
			<view class="header">
				<image class="image" :src="imgurl+listBackdropImg" mode="widthFix"></image>
			</view>


		</view> -->
		<!-- <view class="history-top">
			<view class="history-fh" @click="nextpagefun">
			</view>
			<view class="history-title">
				动作列表
			</view>
			<view class="history-home" @click="homepagefun">
			</view>
		</view>

		<view class="on-hx">
			<view class="on-hx-ct">

			</view>
		</view> -->

		<view class="content">

			<!-- 	<view class="content-img">

				<image v-if="activityobj.coverImg" :src="imgurl+activityobj.coverImg" mode=""></image>
				<image v-if="activityobj.posterBackdropImg" :src="imgurl+activityobj.posterBackdropImg" mode=""></image>
				

			</view> -->
			<!-- <view class="content-baimg" v-if="activityobj.bannerImg">
				<image :src="imgurl+activityobj.bannerImg" mode="widthFix"></image>
			</view>
			<view class="content-rlue" v-if="activityobj&&activityobj.rule">
				{{activityobj&&activityobj.rule}}
			</view> -->
			<view class="content-item" v-for="(item,index) in activitylist" :key="index">
				<image class="image-bg-in" :src="imgurl+item.image" mode="widthFix">
				</image>
				<view class="content-infotop">


					<!-- <view class="content-iconortitle">

						<view class="content-iconortitle-lible">{{item.label}}</view>
						<view>
							{{item.beginDate}}
						</view>
						<view class="end-time">

						</view>
					</view> -->
					<view class="content-item-bt">
						<view class="gopay" @click="goenpay(item)" v-if="item.reachFlag!==1">
							去运动
						</view>
						<!-- <view class="goshop" v-if="item.reachFlag==0" >
					未达标
				</view> -->
						<view class="goshop" v-if="item.reachFlag==1">
							已达标
						</view>
					</view>

				</view>


			</view>

		</view>

		<!-- <u-popup v-model="payshow" mode="center" border-radius="35" :mask-close-able="false" :closeable="false"
			:overlay="true">
			<view class="fail-k payshow-k">
				<image src="../../../src/static/images/icon-tk.png" mode="widthFix"></image>
				<view class="kuan-item">
					<view class="fail-content jnshow-content" v-html="shuoming">
					</view>
					<view class="payshow-bt">
						<button @click="()=>{payshow=false}">已知晓活动规则</button>
					</view>
				</view>

			</view>
		</u-popup> -->

		<view class="show-k" v-if="payshow">
			<view class="show-k-item">
				<view class="show-kitem-title">
					<image src="../../static/images/icon-tk.png" mode="widthFix"></image>

				</view>
				<view class="show-k-text">
					<view class="fail-content jnshow-content" v-html="shuoming">
					</view>
					<view class="payshow-bt">
						<button @click="()=>{payshow=false}">已知晓活动规则</button>
					</view>
				</view>

			</view>


		</view>

		<view class="show-k" v-if="shopshow" @click="()=>{shopshow=false}">
			<view class="show-k-item" @click.stop>
				<view class="show-kitem-title">
					<image src="../../../src/static/images/icon-tk.png" mode="widthFix"></image>

				</view>
				<view class="show-k-text" style="padding-top: 400rpx;">
					<view class="fail-content jnshow-content">
						已达标，可以去商城shopping啦！
					</view>
					<view class="payshow-bt">
						<button @click="goshopfunin()">快马加鞭去商城</button>
					</view>
				</view>

			</view>


		</view>


		<!-- 跳 -->
		<!-- <view class="content" v-if="type=='sport'">
		
		<view class="content-item content-itemsport" v-for="(item,index) in activitylist" :key="index">
			<view class="content-itemsport-title">
				
			
			<view class="content-itemsport-title-img">
				<image :src="imgurl+item.coverImg" mode="widthFix"></image>
			</view>
			<view class="content-item-bt">
				<view class="gopay" @click="goenpay(item)">
					去参加活动
				</view>
				<view class="goshop" @click="goshop(item.jumpShopLink)">
					去商城
				</view>
				<view class="peple">
					<text>{{item.showJoinNum}}人参与</text>
					
				</view>
			</view>
			
			</view>
			<view class="content-infosport">
				<view class="content-info-iconortitle">
					
					<text>{{item.name}}</text>
				</view>
				
			</view>
			
		</view>
		
		
	
		
	</view> -->
		<!-- 微信步数 -->
		<!-- <view class="content" v-if="type=='walk'">
		
		<view class="content-item content-itemsport" v-for="(item,index) in activitylist" :key="index">
			<view class="content-itemsport-title">
				
			
			<view class="content-itemsport-title-img">
				<image :src="imgurl+item.coverImg" mode="widthFix"></image>
				
			</view>
			<view class="content-item-bt">
				<view class="gopay" @click="goenpay(item)">
					去参加活动
				</view>
				<view class="goshop" @click="goshop(item.jumpShopLink)">
					去商城
				</view>
				<view class="peple">
					<text>{{item.showJoinNum}}人参与</text>
					
				</view>
			</view>
			
			</view>
			<view class="content-infosport">
				<view class="content-info-iconortitle">
					
					<text>{{item.name}}</text>
				</view>
				
			</view>
			
		</view>
		
		
	
		
	</view> -->
		<!-- 微信步数 -->
		<!-- <view class="content" v-if="type=='study'">
		
		<view class="content-item content-itemsport" v-for="(item,index) in activitylist" :key="index">
			<view class="content-itemsport-title">
				
			
			<view class="content-itemsport-title-img">
				<image :src="imgurl+item.coverImg" mode="widthFix"></image>
				
			</view>
			<view class="content-item-bt">
				<view class="gopay" @click="goenpay(item)">
					去参加活动
				</view>
				<view class="goshop" @click="goshop(item.jumpShopLink)">
					去商城
				</view>
				<view class="peple">
					<text>{{item.showJoinNum}}人参与</text>
					
				</view>
			</view>
			
			</view>
			<view class="content-infosport">
				<view class="content-info-iconortitle">
				
					<text>{{item.name}}</text>
				</view>
				
			</view>
			
		</view> -->




		<!-- </view> -->

		<u-empty text="暂无记录" v-if="activitylist.length==0" mode="list" :margin-top="180"></u-empty>










	</view>
</template>

<script>
	import {
		getJumpShopUrl,
		getActivityDetails
	} from "@/api/index/index";
	import {
		BASE_URL_IMAHE
	} from "../../../utils/https";

	const app = getApp();
	export default {
		data() {
			return {
				form: {
					userRef: "",
					activityId: '',
				},
				activitylist: [],
				imgurl: BASE_URL_IMAHE,
				listBackdropImg: '',
				type: "",
				toall: 0,
				activityobj: {},
				shuoming: '',
				payshow: true,
				shopshow: false,
				atjumpShopLink: "",

			};
		},

		created() {},
		beforeDestroy() {

		},

		onLoad(e) {
			console.log(e)
			uni.setStorageSync('showinde', "0")


			this.type = uni.getStorageSync("type")


			// if(uni.getStorageSync("type")=="chess"){
			this.form.userRef = uni.getStorageSync("userRef")
			this.form.activityId = e.activityId
			if (e.activityId) {

			} else {
				uni.reLaunch({
					url: "/pages/home/index"
				})
			}
			// }
			// if(uni.getStorageSync("type")=="sport"){

			//  this.form.userRef=uni.getStorageSync("usersportRef")	
			// }

			// if(uni.getStorageSync("type")=="walk"){

			// 		  this.form.userRef=uni.getStorageSync("userwalkRef")	
			// }
			// if(uni.getStorageSync("type")=="study"){

			// 		  this.form.userRef=uni.getStorageSync("userstudyRef")	
			// }
			// console.log(uni.getStorageSync("type"),uni.getStorageSync("usersportRef"),this.form.userRef)





		},
		onShow() {

			// this.form.v=uni.getStorageSync("v")
			this.listBackdropImg = uni.getStorageSync('listBackdropImg') ? uni.getStorageSync('listBackdropImg') : ""
			this.activitylist = [],
				this.getlist()
			const constraints = {
				audio: true,
				video: true
			}; // 设置只需要视频流而不包含音频
			// if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
			// 	navigator.mediaDevices.getUserMedia({
			// 			video: true
			// 		})
			// 		.then(function(stream) {


			// 		})
			// 		.catch((error) => {
			// 			console.log("无法打开摄像头", error);
			// 		});
			// }

		},

		onReady() {

		},
		onReachBottom() {
			console.log("到底部 加载更多");
			//请求订单
			// if(this.form.pageNo>this.toall){
			//  return
			// }
			// this.getlist()
		},
		methods: {

			async goshop(id) {
				let data = {
					activityId: id,
					userRef: uni.getStorageSync("userRef")
				}
				const res = await getJumpShopUrl(JSON.stringify(data))
				if (res.result == 0) {
					window.location.href = res.jumpShopLink
				} else {
					uni.showToast({
						title: res.message,
						icon: "none"
					})
				}
			},
			async getlist() {
				const resbeginActivity = await getActivityDetails(JSON.stringify(this.form))
				console.log(resbeginActivity.actionList)
				this.activityobj = resbeginActivity.activity
				this.shuoming = resbeginActivity.activity.rule
				this.activitylist.push(...resbeginActivity.actionList)

				if (resbeginActivity.jumpShopLink) {
					this.payshow = false
					this.shopshow = true
					this.atjumpShopLink = resbeginActivity.jumpShopLink
				}

				// else {
				// 	this.payshow = true
				// 	this.shopshow = false
				// }
				// #ifdef MP-WEIXIN
				this.form.type = 2
				// #endif
				// const res=await getActivityPage(JSON.stringify(this.form))
				// console.log(res)
				// this.toall=Math.ceil(res.page.count/res.page.pageSize)

				// this.form.pageNo++



			},
			goshopfunin() {
				window.location.href = this.atjumpShopLink
			},
			goenpay(item) {
				uni.navigateTo({
					url: `/pages/sport/index?activityId=${this.form.activityId}&actionId=${item.id}`
				})

			},
			nextpagefun() {
				// 跳转回原页面
				// uni.navigateBack({
				//   delta: 1,
				// });
				uni.reLaunch({
					url: "/pages/home/index"
				})

			},
			homepagefun() {
				uni.reLaunch({
					url: "/pages/home/index"
				})
			},
		}


	};
</script>

<style lang="scss" scoped>
	.btstyle {
		width: 165rpx;
		background: #0065ff;
		color: white;
	}

	u-checkbox-group::v-deep {
		.u-checkbox__label {
			margin-right: rpx(0);
		}
	}

	.icon-cone {
		margin-right: 10rpx;
	}

	.checkBox_wrapper {
		font-size: rpx(12);
		display: flex;
	}

	.container {
		padding: 0 0rpx;
		font-size: 32rpx;
		background: #fff;
		min-height: 100vh;
		position: relative;
		padding-bottom: 20rpx;
	}

	.back_img {
		position: absolute;
		top: 80rpx;
		right: 0rpx;
		z-index: 1;

		image {
			width: 350rpx;
		}
	}

	.login-test {
		margin-top: rpx(20);

		display: flex;
		justify-content: center;

		.login-item {
			width: rpx(80);
			height: rpx(80);
			text-align: center;
			margin-left: rpx(20);
			margin-right: rpx(20);

			.login-text {
				width: 100%;
				font-size: rpx(15);
				line-height: rpx(35);
			}

			.login-icom {

				// width: rpx(48);
				// height: rpx(48);
				// border-radius: 50%;
				// border: rpx(3) solid black;
				// margin: 0 auto;
				.login-icoms {}
			}
		}
	}

	.wechatapp {
		//border-bottom: 1rpx solid #e3e3e3;
		// margin-bottom: 72rpx;
		text-align: center;
		width: 100%;
		height: 128rpx;
		overflow: hidden;
		position: relative;

		.header {
			width: 100%;
			height: 100%;



			.image {
				width: 100%;
				height: 100%;
			}
		}
	}

	.auth-title {
		color: #585858;
		font-size: 60rpx;
		margin-bottom: 40rpx;
		margin-left: 40rpx;
		margin-top: 80rpx;
	}

	.auth-phonetitle {
		color: #585858;
		font-size: 30rpx;
		margin-bottom: 40rpx;
		margin-left: 40rpx;
		line-height: 60rpx;
		margin-top: 80rpx;
	}

	.auth-subtitle {
		color: #888;
		margin-bottom: 88rpx;
		font-size: 60rpx;

	}

	.login-view {
		width: 100%;
		box-sizing: border-box;
		padding: 0 rpx(20);
	}

	.login-btn-qk {
		font-size: 30rpx;
		text-align: right;
		margin-right: 40rpx;
		margin-top: 40rpx;
	}

	.content-k {
		display: flex;
		justify-content: space-between;
		padding: 60rpx 48rpx 0rpx;
	}

	.history-top {
		margin: 0 auto;
		width: 655rpx;
		height: 142rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;

		.history-title {
			font-size: 34rpx;
			color: #0065ff;
		}

		.history-fh {
			image {
				width: 18rpx;
				height: 32rpx;
			}
		}

		.history-home {
			image {
				width: 42rpx;
				height: 44rpx;
			}
		}
	}

	.on-hx {
		width: 749rpx;
		height: 5rpx;
		background-color: #f2f6fe;

		.on-hx-ct {
			width: 100%;
			height: 5rpx;
			background-color: #0065ff;
		}
	}

	.content {
		width: 655rpx;
		height: auto;
		margin: 0rpx auto 0rpx;
		padding-top: 102rpx;

		.content-img {
			display: flex;
			justify-content: space-between;
			align-items: center;

			image {
				width: 200rpx;
				height: 200rpx;
			}
		}

		.content-baimg {
			width: 100%;

			image {
				width: 100%;
				height: auto;
			}
		}

		.content-rlue {
			padding-bottom: 30rpx;
			margin-top: 30rpx;
			white-space: pre-wrap;
			font-size: 36rpx;
			line-height: 40rpx;

		}

		.content-item {
			width: 676rpx;
			height: 260rpx;
			// border: 4rpx solid #0f62f9;
			border-radius: 35rpx;
			box-sizing: border-box;
			// padding: 40rpx 37rpx 40rpx 30rpx;
			margin-bottom: 28rpx;
			overflow: hidden;
			position: relative;

			.image-bg-in {
				width: 100%;
				height: auto;
			}

			.content-infotop {
				position: absolute;
				text-align: left;
				display: flex;
				justify-content: space-between;
				bottom: 31rpx;

				.content-iconortitle {
					display: flex;
					align-items: center;
					flex-direction: column;
					text-align: left;

					image {
						width: 118rpx;
						height: 118rpx;
					}

					.content-iconortitle-lible {
						width: 100%;
						// margin-left: 25rpx;
						font-size: 34rpx;
						text-align: left;
					}

					view {
						margin-top: 20rpx;
					}

					.end-time {
						margin-top: 0rpx;
					}
				}

				.gopay {
					// display: inline;
					white-space: nowrap;
					color: #ffffff;
					text-align: center;
					line-height: 61rpx;
					width: 167rpx;
					height: 61rpx;
					background: #FFFFFF;
					border-radius: 31rpx;
					font-weight: 500;
					font-size: 29rpx;
					color: #67348A;
					text-align: center;
					margin-left: 37rpx;

				}

				.goshop {
					white-space: nowrap;
					color: #ffffff;
					text-align: center;
					line-height: 60rpx;
					width: 168rpx;
					height: 62rpx;
					border-radius: 31rpx;
					border: 1px solid #FFFFFF;
					border-radius: 31rpx;
					ont-weight: 500;
					font-size: 29rpx;
					color: #FFFFFF;
					text-align: center;
					margin-left: 37rpx;

				}
			}

			.content-info {
				display: flex;
				justify-content: space-between;
				margin-top: 73rpx;

				.content-info-iconortitle {
					display: flex;
					align-items: center;

					image {
						width: 22rpx;
						height: 22rpx;
					}

					text {
						margin-left: 10rpx;
						font-size: 24rpx;
						color: #8e9aab;
					}
				}

				.content-info-time {
					font-size: 24rpx;
					color: #5e6f88;
				}
			}
		}

		.content-itemsport {
			padding: 0;
			overflow: hidden;
			height: auto;
			border: none;
			border-top-left-radius: 35rpx;
			border-top-right-radius: 35rpx;
			border-bottom-left-radius: 0rpx;
			border-bottom-right-radius: 0rpx;

			.content-itemsport-title {
				width: 100%;
				height: 288rpx;
				overflow: hidden;
				position: relative;

				.content-itemsport-title-img {
					width: 100%;
					height: auto;

					image {
						width: 100%;
						height: auto;
					}
				}
			}

			.content-infosport {
				height: 80rpx;
				font-size: 40rpx;
				text-align: left;
				font-weight: bold;
				line-height: 80rpx;
				padding-left: 20rpx;
				background-color: #f5f5f5;

			}

			.content-item-bt {
				position: absolute;
				width: auto;
				right: 20rpx;
				top: 40rpx;
				display: flex;
				flex-direction: column;
				justify-content: flex-end;
				align-items: flex-end;
			}

			.gopay {

				display: inline;
				white-space: nowrap;
				padding: 5rpx 20rpx;
				font-size: 24rpx;
				border-radius: 45rpx;
				background-color: #0065ff;
				color: #ffffff;
				text-align: center;
				// line-height: 37rpx;
				margin-left: 0rpx;

			}

			.goshop {
				width: 108rpx;
				height: 37rpx;
				font-size: 24rpx;
				border-radius: 45rpx;
				background-color: #0065ff;
				color: #ffffff;
				text-align: center;
				line-height: 37rpx;
				margin-top: 36rpx;
				// margin: 36rpx auto 0rpx;
				margin-left: 0rpx;

			}

			.peple {
				width: auto;
				height: 37rpx;
				line-height: 37rpx;
				margin-top: 36rpx;

				text {
					font-size: 24rpx;
					border-radius: 45rpx;
					background-color: rgba(0, 0, 0, 0.5);
					color: white;
					text-align: center;
					padding: 2rpx 10rpx;
				}
			}

		}


	}

	.fail-kan {
		padding-top: 100rpx;
		height: auto;
		// width: 600rpx;

		.fail-title {
			padding-top: 20rpx;
			color: #8a0002;
			font-size: 38rpx;
		}

		.fail-num {
			font-size: 120rpx;
			color: #8a0002;
		}

		.fail-max {
			margin-top: 40rpx;
			font-size: 24rpx;
			color: #000000;
		}

		.fail-content {
			font-size: 24rpx;
			padding-top: 64rpx;
			color: #8a0002;
			white-space: pre-wrap;
		}

		.fail-bt {
			margin: 55rpx auto 0rpx;
			width: 492rpx;
			height: 95rpx;
			background-color: #730017;
			font-size: 30rpx;
			color: #ffffff;
			border-radius: 15rpx;
			line-height: 95rpx;

		}

		.fail-bt-new {
			margin: 15rpx auto 0rpx;
			width: 492rpx;
			height: 95rpx;
			background-color: #ffffff;
			font-size: 30rpx;
			color: #730017;
			box-sizing: border-box;
			border: 2rpx solid #730017;
			border-radius: 15rpx;
			line-height: 95rpx;
		}
	}

	// 弹框
	.fail-k {
		width: 490rpx;
		height: auto;
		text-align: center;
		background-color: #794596 !important;

		image {
			width: 100%;
			position: absolute;
			top: 0;
			left: 0;
		}

		.fail-title {
			padding-top: 120rpx;
			font-size: 36rpx;
			font-weight: bold;
			color: #111827;
		}

		.fail-content {
			margin-top: 29rpx;
			font-size: 24rpx;
			font-weight: bold;
			color: #718096;
		}

		.fail-bt {
			margin: 55rpx auto 0rpx;
			// width: 328rpx;
			// height: 64rpx;
			background-color: #292c34;
			color: #ffffff;
			border-radius: 35rpx;
			line-height: 64rpx;

		}

	}

	.payshow-k {
		width: 390rpx;

		// padding-bottom: 100rpx;
		position: relative;


		.jnshow-title {
			padding-top: 50rpx;
			font-size: 36rpx;
			font-weight: bold;
			color: #111827;

		}

		.kuan-item {
			position: relative;
			top: 317rpx
		}


	}

	.show-k {
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		right: 0;
		background: rgba(0, 0, 0, 0.5);
		display: flex;
		justify-content: center;
		align-items: center;

		.show-k-item {
			width: 490rpx;
			height: auto;
			text-align: center;
			background-color: #794596 !important;
			position: relative;
			border-radius: 35rpx;

			.show-kitem-title {
				width: 100%;
				position: absolute;
				top: 0;
				left: 0;
			}

			image {
				width: 100%;
				// position: absolute;
				top: 0;
				left: 0;
			}

			.show-k-text {
				position: relative;
				padding-top: 315rpx;
				padding-bottom: 50rpx;
			}
		}
	}

	.fail-content {
		font-size: 24rpx;
		padding-top: 64rpx;
		color: #8a0002;
		white-space: pre-wrap;
	}

	.jnshow-content {
		// position: absolute;
		// bottom: 151rpx;
		font-weight: 500;
		font-size: 24rpx;
		color: #FFFFFF;
		line-height: 36rpx;
		padding: 0 50rpx;
		white-space: pre-wrap;
		text-align: left;
		// top: 317rpx;
		// padding-bottom: 200rpx;
	}

	.payshow-bt {
		width: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 20rpx;
		margin-top: 41rpx;


		button {
			width: 328rpx;
			height: 62rpx;
			background: #FFFFFF;
			border-radius: 31rpx;
			font-weight: 500;
			font-size: 30rpx;
			color: #653289;
			line-height: 62rpx;
		}
	}
</style>